;; refer http://julienblanchard.com/2016/fancy-rust-development-with-emacs/

;;
(add-hook 'rust-mode-hook #'racer-mode)
(add-hook 'racer-mode-hook #'eldoc-mode)

(add-hook 'racer-mode-hook #'company-mode)
(add-hook 'rust-mode-hook #'rainbow-delimiters-mode)

(require 'rust-mode)
(define-key rust-mode-map (kbd "TAB") #'company-indent-or-complete-common)
(setq company-tooltip-align-annotations t)


;; setup rust

;; (add-hook 'rust-mode-hook 'cargo-minor-mode)
;; (add-hook 'rust-mode-hook
;;           (lambda ()
;;             (local-set-key (kbd "C-c <tab>") #'rust-format-buffer)))

;; (defun indent-buffer ()
;;   "Intent current buffer according to major mode."
;;   (interactive)
;;   (indent-region (point-min) (point-max)))

;; (setq racer-cmd "~/.cargo/bin/racer")
;; (setq racer-rust-src-path "~/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/src/rust/src")
;; ;;(setq racer-rust-src-path "~/.cargo/src/rust/src")

;; (add-hook 'rust-mode-hook #'racer-mode)
;; (add-hook 'rust-mode-hook #'eldoc-mode)
;; (add-hook 'rust-mode-hook #'company-mode)
;; (add-hook 'rust-mode-hook #'electric-pair-mode)
;; (add-hook 'rust-mode-hook #'electric-indent-mode)

